home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 August (Alt) / CHIP 2005-08.1.iso / program / shareware / Flash_Oyunlar.exe / rocketbike.swf / scripts / frame_2 / DoAction.as < prev   
Encoding:
Text File  |  2005-07-13  |  9.2 KB  |  385 lines

  1. function setscreen(sc)
  2. {
  3.    if(sc == "back")
  4.    {
  5.       loopb = true;
  6.       front[7]._visible = false;
  7.       while(loopb)
  8.       {
  9.          loopb = false;
  10.          screen = backscreen[screencounter];
  11.          screencounter--;
  12.          if(screencounter <= 1)
  13.          {
  14.             front[4].choice.gotoAndStop("new");
  15.          }
  16.          if(screen == "about" or screen == "help")
  17.          {
  18.             loopb = true;
  19.          }
  20.       }
  21.    }
  22.    else if(sc == "reset")
  23.    {
  24.       front[7]._visible = false;
  25.       screencounter = 0;
  26.       front[4].choice.gotoAndStop("new");
  27.    }
  28.    else
  29.    {
  30.       screencounter++;
  31.       backscreen[screencounter] = screen;
  32.       screen = sc;
  33.    }
  34. }
  35. function useweapon(who)
  36. {
  37.    if(weaponcounter[who] >= 1 and mode[who] == "ground")
  38.    {
  39.       weaponcounter[who]--;
  40.       if(weaponcounter[who] < 1)
  41.       {
  42.          weaponface.gotoAndStop(1);
  43.          weapon[who] = null;
  44.       }
  45.       tracklength++;
  46.       obstacles.attachMovie("obstacle",tracklength,tracklength);
  47.       obstacles[tracklength].kind = weapon[who];
  48.       if(who == human)
  49.       {
  50.          obstacles[tracklength].human = true;
  51.       }
  52.       playsound("drop");
  53.       if(xvel[who] > 0)
  54.       {
  55.          margin = -50;
  56.       }
  57.       else
  58.       {
  59.          margin = 20;
  60.       }
  61.       obstacles[tracklength]._x = bikes[who]._x - obstacles._x + margin;
  62.       obstacles[tracklength]._y = bikes[who]._y - obstacles._y;
  63.    }
  64. }
  65. function usextra(who)
  66. {
  67.    if(xtra[who] == "fuel")
  68.    {
  69.       eval("xtraloop" + who).onEnterFrame = function()
  70.       {
  71.          if(!paused)
  72.          {
  73.             if(xtracounter[who] == 1 and who == human)
  74.             {
  75.                playsound("accel");
  76.                damagebike(who,(0.08 + engine[who] / 3) * 99);
  77.             }
  78.             xtracounter[who]++;
  79.             bikes[who].chase.b.gotoAndStop("horse");
  80.             xvel[who] *= 1.05;
  81.             if(xtracounter[who] > 99)
  82.             {
  83.                xtracounter[who] = 0;
  84.                bikes[who].chase.b.horse.gotoAndPlay("off");
  85.                delete eval("xtraloop" + who).onEnterFrame;
  86.             }
  87.          }
  88.       };
  89.    }
  90.    else if(xtra[who] == "repair")
  91.    {
  92.       eval("xtraloop" + who).onEnterFrame = function()
  93.       {
  94.          if(!paused)
  95.          {
  96.             xvel[who] *= 0.8;
  97.             damagebike(who,-0.1);
  98.             if(damage[who] < 1)
  99.             {
  100.                delete eval("xtraloop" + who).onEnterFrame;
  101.             }
  102.          }
  103.       };
  104.    }
  105. }
  106. function changemoney(much)
  107. {
  108.    money += much;
  109.    mymoney = "$" + money;
  110.    starsbox.gotoAndPlay(2);
  111. }
  112. function damagebike(which, much)
  113. {
  114.    damage[which] += much + much * (4 - cauchomodel[which]) / 4;
  115.    if(which == human)
  116.    {
  117.       heat.gotoAndStop(Math.floor(damage[which]));
  118.       if(much > 0 and damage[which] > 20)
  119.       {
  120.          if(damage[which] < 50)
  121.          {
  122.             msg.txt = "HEATING!";
  123.          }
  124.          else if(damage[which] < 70)
  125.          {
  126.             msg.txt = "HEATING!";
  127.          }
  128.          else if(damage[which] < 100)
  129.          {
  130.             msg.txt = "OVERLOADING!";
  131.          }
  132.          else if(damage[which] > 100)
  133.          {
  134.             msg.txt = "ENGINE OVERLOADED!";
  135.          }
  136.          msg.gotoAndPlay(2);
  137.       }
  138.    }
  139.    if(damage[which] > 100)
  140.    {
  141.       explodecounter[which] = 2;
  142.       eval("xtraloop" + which).onEnterFrame = null;
  143.       mytrack[which] = bikes[which]._y;
  144.       yvel[which] = -15;
  145.       mode[which] = "falling";
  146.       keyb[which] = false;
  147.    }
  148. }
  149. function forcewinners()
  150. {
  151.    motorsnd.stop();
  152.    tosort = new Array();
  153.    winnerlist = new Array();
  154.    n = 1;
  155.    while(n <= muchbikes)
  156.    {
  157.       tosort[n] = kilometer[n];
  158.       n++;
  159.    }
  160.    tosort.sort();
  161.    n = 1;
  162.    while(n <= muchbikes)
  163.    {
  164.       s = 1;
  165.       while(s <= muchbikes)
  166.       {
  167.          if(tosort[n] == kilometer[s])
  168.          {
  169.             winnerlist[n] = s;
  170.          }
  171.          s++;
  172.       }
  173.       n++;
  174.    }
  175.    n = 1;
  176.    while(n <= muchbikes)
  177.    {
  178.       tosort[n] = winnerlist[muchbikes - n + 1];
  179.       n++;
  180.    }
  181.    muchwinners = muchbikes;
  182.    if(muchwinners > 3)
  183.    {
  184.       muchwinners = 3;
  185.    }
  186.    while(arrived < muchwinners)
  187.    {
  188.       arrived++;
  189.       f = 1;
  190.       while(f <= muchwinners)
  191.       {
  192.          if(playerstate[tosort[f]] != "winner")
  193.          {
  194.             winner[arrived] = tosort[f];
  195.             if(playerstate[tosort[f]] == "alive")
  196.             {
  197.                myminutes = 0;
  198.                myseconds = Math.round(14 * (muchbikes + f) + random(10));
  199.                if(myseconds > 60)
  200.                {
  201.                   myseconds -= 60;
  202.                   if(myseconds < 10)
  203.                   {
  204.                      myseconds += "0";
  205.                   }
  206.                   myminutes++;
  207.                }
  208.                winnertime[arrived] = "0" + myminutes + ":" + myseconds + ":" + Math.round(Number(arrived * (random(7) + 10)));
  209.             }
  210.             else
  211.             {
  212.                if(bikers[tosort[f]] == bikers[human])
  213.                {
  214.                   temphuman = bikers[human];
  215.                }
  216.                bikers[tosort[f]] = 7;
  217.                winnertime[arrived] = "99:99:99";
  218.             }
  219.             playerstate[tosort[f]] = "winner";
  220.             break;
  221.          }
  222.          f++;
  223.       }
  224.    }
  225.    screen = "winners";
  226.    front.play();
  227.    paused = true;
  228. }
  229. function savegame()
  230. {
  231.    saved.data.muchbikes = muchbikes;
  232.    saved.data.biker = bikers[human];
  233.    saved.data.saved = 1;
  234.    saved.data.caucho = caucho;
  235.    saved.data.motor = motor;
  236.    saved.data.engine = engine[human];
  237.    saved.data.cauchomodel = cauchomodel[human];
  238.    saved.data.weapon = weapon[human];
  239.    saved.data.weaponcounter = weaponcounter[human];
  240.    saved.data.xtra = xtra[human];
  241.    saved.data.money = money;
  242. }
  243. function loadgame()
  244. {
  245.    muchbikes = human = saved.data.muchbikes;
  246.    bikers[human] = models[human] = saved.data.biker;
  247.    caucho = saved.data.caucho;
  248.    motor = saved.data.motor;
  249.    engine[human] = saved.data.engine;
  250.    cauchomodel[human] = saved.data.cauchomodel;
  251.    weapon[human] = saved.data.weapon;
  252.    weaponcounter[human] = saved.data.weaponcounter;
  253.    xtra[human] = saved.data.xtra;
  254.    money = saved.data.money;
  255.    mymoney = "$" + money;
  256. }
  257. function murdered()
  258. {
  259.    if(murder == false)
  260.    {
  261.       murder = true;
  262.       if(explodecounter[human] < 0)
  263.       {
  264.          damagebike(human,200);
  265.       }
  266.       if(winnercounter[human] > 0)
  267.       {
  268.          winnercounter[human] = -10;
  269.          obstacles._x += 2;
  270.          xvel[human] *= -10;
  271.          bikes[human]._x -= 10;
  272.       }
  273.       mafiamission = "failed";
  274.       paused = true;
  275.       mafia.play();
  276.    }
  277. }
  278. function soundbase(which)
  279. {
  280.    sndtrack.stop();
  281.    sndtrack = null;
  282.    sndtrack = new Sound(snd1);
  283.    sndtrack.attachSound(which);
  284.    sndtrack.setVolume(60);
  285.    sndtrack.start(0,999999999);
  286. }
  287. function playsound(which)
  288. {
  289.    eventsound = null;
  290.    eventsound = new Sound(snd2);
  291.    eventsound.attachSound(which);
  292.    eventsound.start();
  293. }
  294. gravity = 1;
  295. friction = 0.9;
  296. bounce = 0.3;
  297. human = 1;
  298. motorstarted = false;
  299. explodecounter = new Array();
  300. fadebike = new Array();
  301. cauchomodel = new Array();
  302. motorkind = new Array();
  303. engine = new Array();
  304. xvel = new Array();
  305. playerstate = new Array();
  306. yvel = new Array();
  307. bikelaps = new Array();
  308. kilpercent = new Array();
  309. kilometer = new Array();
  310. mode = new Array();
  311. mytrack = new Array();
  312. bikers = new Array();
  313. models = new Array();
  314. rampcounter = new Array();
  315. rotatecounter = new Array();
  316. oilcounter = new Array();
  317. tachuelascounter = new Array();
  318. gumcenter = new Array();
  319. gumcounter = new Array();
  320. poisoncounter = new Array();
  321. ongroundcounter = new Array();
  322. mytrackcounter = new Array();
  323. weapon = new Array();
  324. weaponcounter = new Array();
  325. xtra = new Array();
  326. xtracounter = new Array();
  327. xtracounter = new Array();
  328. keyb = new Array();
  329. damage = new Array();
  330. muchbikes = 4;
  331. n = 1;
  332. while(n <= muchbikes)
  333. {
  334.    xvel[n] = 0.1;
  335.    engine[n] = 1;
  336.    cauchomodel[n] = 1;
  337.    motorkind = 1;
  338.    n++;
  339. }
  340. center = 300;
  341. rightcenter = center + center / 2;
  342. leftcenter = center - center / 2;
  343. trackcounter = 0;
  344. seconds = minutes = milliseconds = 0;
  345. heat[n].model.gotoAndStop(1);
  346. weaponitems = new Array();
  347. weaponitems[0] = "blank";
  348. weaponitems[1] = "banana";
  349. weaponitems[2] = "tachuelas";
  350. weaponitems[3] = "gum";
  351. weaponitems[4] = "poison";
  352. xtraitems = new Array();
  353. xtraitems[0] = "blank";
  354. xtraitems[1] = "repair";
  355. xtraitems[2] = "fuel";
  356. backscreen = new Array();
  357. muchbikes = 2;
  358. winnercounter = new Array();
  359. winner = new Array();
  360. winnertime = new Array();
  361. arrived = 0;
  362. obstaclekind = new Array();
  363. obstaclekind[0] = "grass";
  364. obstaclekind[1] = "jumper";
  365. obstaclekind[2] = "oil";
  366. obstaclekind[3] = "dumb";
  367. obstaclekind[4] = "ramp";
  368. obstaclekind[5] = "star";
  369. motor = "motor1";
  370. caucho = "caucho1";
  371. tracklength = 10;
  372. changemoney(150);
  373. order = new Array();
  374. saved = SharedObject.getLocal("sikidsrb");
  375. score = saved.data.score;
  376. playername = new Array();
  377. playername[1] = "rocket dude";
  378. playername[2] = "alien farm";
  379. playername[3] = "red gallito";
  380. playername[4] = "punk guy";
  381. playername[5] = "blue elvis";
  382. playername[6] = "evil clown";
  383. motorsnd = new Sound(snd3);
  384. motorsnd.attachSound("motorsnd");
  385.